<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Created by CodeTlan.
 * User: Ing. Miguel Salas
 * Date: 3/4/12
 * Time: 9:28 PM
 */
class Categorias extends CT_Controller
{
    function __construct(){
        parent::__construct();
        $this->load->model("categoria", "dao");
    }
    function add(){
        $data["departamento_k"] = $this->input->post('departamento_k');
        $data["nombre"]=$this->input->post("nombre");
        $data["activo"]=1;
        $data["estatus"]=1;
        echo $this->_add($data);
    }
    function edit(){
        $data=(array) json_decode($this->input->post("mod"));
        echo $this->_edit($data,array('categoria_k' => $this->input->post('categoria_k')));
    }

    function delete()
    {
        echo $this->_edit(array("estatus" => 0), array('categoria_k' => $this->input->post('categoria_k')));
    }
    function find(){
        $result=$this->dao->find('categoria_k, departamento_k, nombre, activo',array('departamento_k' => $this->input->post('departamento_k')),$this->input->post("start"),NUM_ROWS);
        echo $this->getSuccess($result);
    }
}
